<HTML>
<HEAD>
<TITLE>[Chapter 19] EventQueue </TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 15:12:10 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch19_20.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 19<br>java.awt Reference</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch19_22.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>EventQueue <img src="gifs/bstar.gif" alt="(New)" border=0></H1>

<H2>Name</H2>

EventQueue <img src="gifs/bstar.gif" alt="(New)" border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch19-REFSECT1-AUTOID.21"></A></h2>
</DIV>


<p>
<img align=middle src="./figs/eventqu.gif" alt="[Graphic: Figure from the text]" width=503 height=53 border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-1">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>EventQueue</tt> class is a facility for queuing Java 1.1 AWT events, either for the system or for some other purpose. You rarely need to create your own event queue; for most purposes, you will want to work with the system's event queue, which you acquire using the <tt CLASS=literal>Toolkit</tt>.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-2">Class Definition</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class EventQueue extends Object {
  // Constructor
  public EventQueue();
  // Instance Methods
  public synchronized AWTEvent getNextEvent() throws InterruptedException;
  public synchronized AWTEvent peekEvent();
  public synchronized AWTEvent peekEvent (int id);
  public synchronized void postEvent (AWTEvent theEvent);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-3">Constructor</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-3.1">EventQueue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-3.1.1">public EventQueue()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Creates an <tt CLASS=literal>EventQueue </tt>for your own use.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-4">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-4.1">getNextEvent</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-4.1.1">public synchronized AWTEvent getNextEvent() throws InterruptedException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Throws <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>InterruptedException</tt><br>
<DD>

<P CLASS=para>
If the 
thread is interrupted before an event is posted to the queue. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>AWTEvent</tt> 
taken from the event queue. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Removes the next event from the event queue and returns it. If there 
are no events in the queue, this method will block until another thread 
posts one. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-4.2">peekEvent</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-4.2.1">public synchronized AWTEvent peekEvent()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Next <tt CLASS=literal>AWTEvent</tt> 
on the event queue. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Returns a reference to the next event on the queue without removing it 
from the queue. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-4.2.2">public synchronized AWTEvent peekEvent (int id)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>id</I><br>
<DD>

<P CLASS=para>
Type of event to find. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>AWTEvent</tt> 
with the given type <tt CLASS=literal>id</tt>; <tt CLASS=literal>null</tt> 
if no event with the given type is currently in the queue. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Returns an event with the given type if one exists, but doesn't remove 
the event from the queue. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-EVENTQUEUE-SECT-5">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>AWTEvent</tt>, <tt CLASS=literal>Event</tt> 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch19_20.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch19_22.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>Event</td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>FileDialog</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
